﻿using System;
using System.IO;
using System.Reflection;
using IBatisNet.DataMapper;
using IBatisNet.DataMapper.Configuration;

namespace CMS.Dao {
	public class IDao {
		private ISqlMapper _sqlmap;
		private static readonly object _lock = new object();

		protected ISqlMapper SqlMapper {
			get {
				if (_sqlmap == null) {
					lock (_lock) {
						if (_sqlmap == null) {
							Stream stream = Assembly.LoadFile(AppDomain.CurrentDomain.BaseDirectory + "bin\\cms.map.dll").GetManifestResourceStream("CMS.Map.config.sqlmap.config");
							_sqlmap = new DomSqlMapBuilder().Configure(stream);
							//_sqlmap = new DomSqlMapBuilder().Configure("config\\sqlmap.config");
						}
					}
				}
				return _sqlmap;
			}
		}
	}
}